package com.qc.searchBug.services;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qc.searchBug.dao.BugInfoMapper;
@Service
public class BugInfoServicesImpl implements BugInfoServices {
	@Autowired
	private BugInfoMapper bugInfo;
	@Override
	public int addBug(Map<String, Object> map) {
		int i=bugInfo.addBugInfo(map);
		
		return i;
	}
	@Override
	public List<Map<String,Object>> findByAjax(Map<String, Object> map) {
		return bugInfo.findByAjax(map);
	}
	@Override
	public List<Map<String,Object>> findByDescription(String description, int indexPage,
			int pageSize) {
		Map<String,Object> map=new HashMap<String, Object>();
		map.put("description", description);
		map.put("indexPage",((indexPage-1)*pageSize));
		map.put("pageSize", pageSize);
		return bugInfo.findByDescription(map);
	}
	@Override
	public Map<String, Object> findByBugId(int bugId) {
		
		return bugInfo.findByBugId(bugId);
	}
	@Override
	public List<Map<String, Object>> findBugByUserId(int userId ,int indexSize, int pageSize) {
		Map<String,Object> map=new HashMap<String, Object>();
		map.put("userId", userId);
		map.put("indexSize", (indexSize-1)*pageSize);
		map.put("pageSize", pageSize);
		return bugInfo.findBugByUserId(map);
	}
	@Override
	public int updateQueriesnumber(int bugId, int queriesnumber) {
		Map<String,Object> map=new HashMap<String, Object>();
		map.put("bugId", bugId);
		map.put("queriesnumber", queriesnumber);
		return bugInfo.updateQueriesnumber(map);
	}
	//查询总共多少条数据
	@Override
	public int findPageNumberByUserId(int userId) {
		return bugInfo.findPageNumberByUserId(userId);
	}
	//按BUGID删除
	@Override
	public int deleteByBugId(int bugId) {
		return bugInfo.deleteByBugId(bugId);
	}
}
